home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / include / afxctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  66.6 KB  |  1,990 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. /////////////////////////////////////////////////////////////////////////////
  12. // AFXCTL.H - MFC OLE Control support
  13.  
  14. #ifndef __AFXCTL_H__
  15. #define __AFXCTL_H__
  16.  
  17. // make sure afxole.h is included first
  18. #ifndef __AFXOLE_H__
  19.     #include <afxole.h>
  20. #endif
  21.  
  22. #ifdef _AFX_MINREBUILD
  23. #pragma component(minrebuild, off)
  24. #endif
  25. #ifndef _AFX_FULLTYPEINFO
  26. #pragma component(mintypeinfo, on)
  27. #endif
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // Classes declared in this file
  31.  
  32. //CWinApp
  33.     class COleControlModule;        // Module housekeeping for an .OCX
  34.  
  35. class CFontHolder;                  // For manipulating font objects
  36. class CPictureHolder;               // For manipulating picture objects
  37.  
  38. //CWnd
  39.     class COleControl;              // OLE Control
  40.  
  41. //CDialog
  42.     class COlePropertyPage;         // OLE Property page
  43.         class CStockPropPage;
  44.             class CColorPropPage;
  45.             class CFontPropPage;
  46.             class CPicturePropPage;
  47.  
  48. class CPropExchange;                // Abstract base for property exchange
  49.  
  50. //CAsyncMonikerFile
  51.     class CDataPathProperty;        // Asynchronous properties for OLE Controls
  52.         class CCachedDataPathProperty;  // Cached asynchronous properties for OLE Controls
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Set structure packing
  56.  
  57. #ifdef _AFX_PACKING
  58. #pragma pack(push, _AFX_PACKING)
  59. #endif
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // MFC data definition for data exported from the runtime DLL
  63.  
  64. #undef AFX_DATA
  65. #define AFX_DATA AFX_OLE_DATA
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // COleControlModule - base class for .OCX module
  69. //  This object is statically linked into the control.
  70.  
  71. class COleControlModule : public CWinApp
  72. {
  73.     DECLARE_DYNAMIC(COleControlModule)
  74. public:
  75.     virtual BOOL InitInstance();
  76.     virtual int ExitInstance();
  77. };
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. //  Module state macro
  81.  
  82. #define AfxGetControlModuleContext  AfxGetStaticModuleState
  83. #define _afxModuleAddrThis AfxGetStaticModuleState()
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // Connection helper functions
  87.  
  88. BOOL AFXAPI AfxConnectionAdvise(LPUNKNOWN pUnkSrc, REFIID iid,
  89.     LPUNKNOWN pUnkSink, BOOL bRefCount, DWORD* pdwCookie);
  90.  
  91. BOOL AFXAPI AfxConnectionUnadvise(LPUNKNOWN pUnkSrc, REFIID iid,
  92.     LPUNKNOWN pUnkSink, BOOL bRefCount, DWORD dwCookie);
  93.  
  94. /////////////////////////////////////////////////////////////////////////////
  95. // Event maps
  96.  
  97. enum AFX_EVENTMAP_FLAGS
  98. {
  99.     afxEventCustom = 0,
  100.     afxEventStock = 1,
  101. };
  102.  
  103. struct AFX_EVENTMAP_ENTRY
  104. {
  105.     AFX_EVENTMAP_FLAGS flags;
  106.     DISPID dispid;
  107.     LPCTSTR pszName;
  108.     LPCSTR lpszParams;
  109. };
  110.  
  111. struct AFX_EVENTMAP
  112. {
  113.     const AFX_EVENTMAP* lpBaseEventMap;
  114.     const AFX_EVENTMAP_ENTRY* lpEntries;
  115.     DWORD* lpStockEventMask;
  116. };
  117.  
  118. #define DECLARE_EVENT_MAP() \
  119. private: \
  120.     static const AFX_DATA AFX_EVENTMAP_ENTRY _eventEntries[]; \
  121.     static DWORD _dwStockEventMask; \
  122. protected: \
  123.     static const AFX_DATA AFX_EVENTMAP eventMap; \
  124.     virtual const AFX_EVENTMAP* GetEventMap() const;
  125.  
  126. #define BEGIN_EVENT_MAP(theClass, baseClass) \
  127.     const AFX_EVENTMAP* theClass::GetEventMap() const \
  128.         { return &eventMap; } \
  129.     const AFX_DATADEF AFX_EVENTMAP theClass::eventMap = \
  130.         { &(baseClass::eventMap), theClass::_eventEntries, \
  131.             &theClass::_dwStockEventMask }; \
  132.     AFX_COMDAT DWORD theClass::_dwStockEventMask = (DWORD)-1; \
  133.     AFX_COMDAT const AFX_DATADEF AFX_EVENTMAP_ENTRY theClass::_eventEntries[] = \
  134.     {
  135.  
  136. #define END_EVENT_MAP() \
  137.         { afxEventCustom, DISPID_UNKNOWN, NULL, NULL }, \
  138.     };
  139.  
  140. #define EVENT_CUSTOM(pszName, pfnFire, vtsParams) \
  141.     { afxEventCustom, DISPID_UNKNOWN, _T(pszName), vtsParams },
  142.  
  143. #define EVENT_CUSTOM_ID(pszName, dispid, pfnFire, vtsParams) \
  144.     { afxEventCustom, dispid, _T(pszName), vtsParams },
  145.  
  146. #define EVENT_PARAM(vtsParams) (BYTE*)(vtsParams)
  147.  
  148. /////////////////////////////////////////////////////////////////////////////
  149. // Stock events
  150.  
  151. #define EVENT_STOCK_CLICK() \
  152.     { afxEventStock, DISPID_CLICK, _T("Click"), VTS_NONE },
  153.  
  154. #define EVENT_STOCK_DBLCLICK() \
  155.     { afxEventStock, DISPID_DBLCLICK, _T("DblClick"), VTS_NONE },
  156.  
  157. #define EVENT_STOCK_KEYDOWN() \
  158.     { afxEventStock, DISPID_KEYDOWN, _T("KeyDown"), VTS_PI2 VTS_I2 },
  159.  
  160. #define EVENT_STOCK_KEYPRESS() \
  161.     { afxEventStock, DISPID_KEYPRESS, _T("KeyPress"), VTS_PI2 },
  162.  
  163. #define EVENT_STOCK_KEYUP() \
  164.     { afxEventStock, DISPID_KEYUP, _T("KeyUp"), VTS_PI2 VTS_I2 },
  165.  
  166. #define EVENT_STOCK_MOUSEDOWN() \
  167.     { afxEventStock, DISPID_MOUSEDOWN, _T("MouseDown"), \
  168.       VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS },
  169.  
  170. #define EVENT_STOCK_MOUSEMOVE() \
  171.     { afxEventStock, DISPID_MOUSEMOVE, _T("MouseMove"), \
  172.       VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS },
  173.  
  174. #define EVENT_STOCK_MOUSEUP() \
  175.     { afxEventStock, DISPID_MOUSEUP, _T("MouseUp"), \
  176.       VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS },
  177.  
  178. #define EVENT_STOCK_ERROREVENT() \
  179.     { afxEventStock, DISPID_ERROREVENT, _T("Error"), \
  180.       VTS_I2 VTS_PBSTR VTS_SCODE VTS_BSTR VTS_BSTR VTS_I4 VTS_PBOOL },
  181.  
  182. #define EVENT_STOCK_READYSTATECHANGE() \
  183.     { afxEventStock, DISPID_READYSTATECHANGE, _T("ReadyStateChange"), \
  184.       VTS_I4 },
  185.  
  186. // Shift state values for mouse and keyboard events
  187. #define SHIFT_MASK      0x01
  188. #define CTRL_MASK       0x02
  189. #define ALT_MASK        0x04
  190.  
  191. // Button values for mouse events
  192. #define LEFT_BUTTON     0x01
  193. #define RIGHT_BUTTON    0x02
  194. #define MIDDLE_BUTTON   0x04
  195.  
  196. /////////////////////////////////////////////////////////////////////////////
  197. // Stock properties
  198.  
  199. #define DISP_PROPERTY_STOCK(theClass, szExternalName, dispid, pfnGet, pfnSet, vtPropType) \
  200.     { _T(szExternalName), dispid, NULL, vtPropType, \
  201.         (AFX_PMSG)(void (theClass::*)(void))&pfnGet, \
  202.         (AFX_PMSG)(void (theClass::*)(void))&pfnSet, 0, afxDispStock }, \
  203.  
  204. #define DISP_STOCKPROP_APPEARANCE() \
  205.     DISP_PROPERTY_STOCK(COleControl, "Appearance", DISPID_APPEARANCE, \
  206.         COleControl::GetAppearance, COleControl::SetAppearance, VT_I2)
  207.  
  208. #define DISP_STOCKPROP_BACKCOLOR() \
  209.     DISP_PROPERTY_STOCK(COleControl, "BackColor", DISPID_BACKCOLOR, \
  210.         COleControl::GetBackColor, COleControl::SetBackColor, VT_COLOR)
  211.  
  212. #define DISP_STOCKPROP_BORDERSTYLE() \
  213.     DISP_PROPERTY_STOCK(COleControl, "BorderStyle", DISPID_BORDERSTYLE, \
  214.         COleControl::GetBorderStyle, COleControl::SetBorderStyle, VT_I2)
  215.  
  216. #define DISP_STOCKPROP_CAPTION() \
  217.     DISP_PROPERTY_STOCK(COleControl, "Caption", DISPID_CAPTION, \
  218.         COleControl::GetText, COleControl::SetText, VT_BSTR)
  219.  
  220. #define DISP_STOCKPROP_ENABLED() \
  221.     DISP_PROPERTY_STOCK(COleControl, "Enabled", DISPID_ENABLED, \
  222.         COleControl::GetEnabled, COleControl::SetEnabled, VT_BOOL)
  223.  
  224. #define DISP_STOCKPROP_FONT() \
  225.     DISP_PROPERTY_STOCK(COleControl, "Font", DISPID_FONT, \
  226.         COleControl::GetFont, COleControl::SetFont, VT_FONT)
  227.  
  228. #define DISP_STOCKPROP_FORECOLOR() \
  229.     DISP_PROPERTY_STOCK(COleControl, "ForeColor", DISPID_FORECOLOR, \
  230.         COleControl::GetForeColor, COleControl::SetForeColor, VT_COLOR)
  231.  
  232. #define DISP_STOCKPROP_HWND() \
  233.     DISP_PROPERTY_STOCK(COleControl, "hWnd", DISPID_HWND, \
  234.         COleControl::GetHwnd, SetNotSupported, VT_HANDLE)
  235.  
  236. #define DISP_STOCKPROP_TEXT() \
  237.     DISP_PROPERTY_STOCK(COleControl, "Text", DISPID_TEXT, \
  238.         COleControl::GetText, COleControl::SetText, VT_BSTR)
  239.  
  240. #define DISP_STOCKPROP_READYSTATE() \
  241.     DISP_PROPERTY_STOCK(COleControl, "ReadyState", DISPID_READYSTATE, \
  242.         COleControl::GetReadyState, SetNotSupported, VT_I4)
  243.  
  244. /////////////////////////////////////////////////////////////////////////////
  245. // Stock methods
  246.  
  247. #define DISP_FUNCTION_STOCK(theClass, szExternalName, dispid, pfnMember, vtRetVal, vtsParams) \
  248.     { _T(szExternalName), dispid, vtsParams, vtRetVal, \
  249.         (AFX_PMSG)(void (theClass::*)(void))&pfnMember, (AFX_PMSG)0, 0, \
  250.         afxDispStock }, \
  251.  
  252. #define DISP_STOCKFUNC_REFRESH() \
  253.     DISP_FUNCTION_STOCK(COleControl, "Refresh", DISPID_REFRESH, \
  254.             COleControl::Refresh, VT_EMPTY, VTS_NONE)
  255.  
  256. #define DISP_STOCKFUNC_DOCLICK() \
  257.     DISP_FUNCTION_STOCK(COleControl, "DoClick", DISPID_DOCLICK, \
  258.             COleControl::DoClick, VT_EMPTY, VTS_NONE)
  259.  
  260. /////////////////////////////////////////////////////////////////////////////
  261. // Macros for object factory and class ID
  262.  
  263. #define BEGIN_OLEFACTORY(class_name) \
  264. protected: \
  265.     class class_name##Factory : public COleObjectFactoryEx \
  266.     { \
  267.     public: \
  268.         class_name##Factory(REFCLSID clsid, CRuntimeClass* pRuntimeClass, \
  269.             BOOL bMultiInstance, LPCTSTR lpszProgID) : \
  270.                 COleObjectFactoryEx(clsid, pRuntimeClass, bMultiInstance, \
  271.                 lpszProgID) {} \
  272.         virtual BOOL UpdateRegistry(BOOL);
  273.  
  274. #define END_OLEFACTORY(class_name) \
  275.     }; \
  276.     friend class class_name##Factory; \
  277.     static AFX_DATA class_name##Factory factory; \
  278. public: \
  279.     static AFX_DATA const GUID guid; \
  280.     virtual HRESULT GetClassID(LPCLSID pclsid);
  281.  
  282. #define DECLARE_OLECREATE_EX(class_name) \
  283.     BEGIN_OLEFACTORY(class_name) \
  284.     END_OLEFACTORY(class_name)
  285.  
  286. #define IMPLEMENT_OLECREATE_EX(class_name, external_name, \
  287.             l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
  288.     const TCHAR _szProgID_##class_name[] = _T(external_name); \
  289.     AFX_DATADEF class_name::class_name##Factory class_name::factory( \
  290.         class_name::guid, RUNTIME_CLASS(class_name), FALSE, \
  291.         _szProgID_##class_name); \
  292.     const AFX_DATADEF GUID class_name::guid = \
  293.         { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }; \
  294.     HRESULT class_name::GetClassID(LPCLSID pclsid) \
  295.         { *pclsid = guid; return NOERROR; }
  296.  
  297. /////////////////////////////////////////////////////////////////////////////
  298. // Macros for type name and misc status
  299.  
  300. #define DECLARE_OLECTLTYPE(class_name) \
  301.     virtual UINT GetUserTypeNameID(); \
  302.     virtual DWORD GetMiscStatus();
  303.  
  304. #define IMPLEMENT_OLECTLTYPE(class_name, idsUserTypeName, dwOleMisc) \
  305.     UINT class_name::GetUserTypeNameID() { return idsUserTypeName; } \
  306.     DWORD class_name::GetMiscStatus() { return dwOleMisc; }
  307.  
  308. /////////////////////////////////////////////////////////////////////////////
  309. // Macros for property page IDs
  310.  
  311. #define DECLARE_PROPPAGEIDS(class_name) \
  312.     protected: \
  313.         virtual LPCLSID GetPropPageIDs(ULONG& cPropPages);
  314.  
  315. #define BEGIN_PROPPAGEIDS(class_name, count) \
  316.     static CLSID _rgPropPageIDs_##class_name[count]; \
  317.     WCE_IF(static, AFX_COMDAT) ULONG _cPropPages_##class_name = (ULONG)-1; \
  318.     LPCLSID class_name::GetPropPageIDs(ULONG& cPropPages) { \
  319.         if (_cPropPages_##class_name == (ULONG)-1) { \
  320.             _cPropPages_##class_name = count; \
  321.             LPCLSID pIDs = _rgPropPageIDs_##class_name; \
  322.             ULONG iPageMax = count; \
  323.             ULONG iPage = 0;
  324.  
  325. #define PROPPAGEID(clsid) \
  326.             ASSERT(iPage < iPageMax); \
  327.             if (iPage < iPageMax) \
  328.                 pIDs[iPage++] = clsid;
  329.  
  330. #define END_PROPPAGEIDS(class_name) \
  331.             ASSERT(iPage == iPageMax); \
  332.         } \
  333.         cPropPages = _cPropPages_##class_name; \
  334.         return _rgPropPageIDs_##class_name; }
  335.  
  336. /////////////////////////////////////////////////////////////////////////////
  337. // CFontHolder - helper class for dealing with font objects
  338.  
  339. class CFontHolder
  340. {
  341. // Constructors
  342. public:
  343.     CFontHolder(LPPROPERTYNOTIFYSINK pNotify);
  344.  
  345. // Attributes
  346.     LPFONT m_pFont;
  347. #if defined(_WIN32_WCE)
  348. // WinCE: guarantee CWCEFont implementation during font property exchanges
  349.     void FontToCeFont();
  350.     void RestoreFont();
  351.     LPFONT m_pSavedFont; 
  352. #endif // _WIN32_WCE
  353.  
  354. // Operations
  355.     void InitializeFont(
  356.             const FONTDESC* pFontDesc = NULL,
  357.             LPDISPATCH pFontDispAmbient = NULL);
  358.     void SetFont(LPFONT pNewFont);
  359.     void ReleaseFont();
  360.     HFONT GetFontHandle();
  361.     HFONT GetFontHandle(long cyLogical, long cyHimetric);
  362.     CFont* Select(CDC* pDC, long cyLogical, long cyHimetric);
  363.     BOOL GetDisplayString(CString& strValue);
  364.     LPFONTDISP GetFontDispatch();
  365.     void QueryTextMetrics(LPTEXTMETRIC lptm);
  366.  
  367. // Implementation
  368. public:
  369.     ~CFontHolder();
  370.     void SetFontNotifySink(LPPROPERTYNOTIFYSINK pNotify);
  371.  
  372. protected:
  373.     DWORD m_dwConnectCookie;
  374.     LPPROPERTYNOTIFYSINK m_pNotify;
  375. };
  376.  
  377. /////////////////////////////////////////////////////////////////////////////
  378. // CPictureHolder - helper class for dealing with picture objects
  379.  
  380. class CPictureHolder
  381. {
  382. // Constructors
  383. public:
  384.     CPictureHolder();
  385.  
  386. // Attributes
  387.     LPPICTURE m_pPict;
  388.  
  389. // Operations
  390.     BOOL CreateEmpty();
  391.  
  392.     BOOL CreateFromBitmap(UINT idResource);
  393. #if !defined(_WIN32_WCE_NO_PALETTE)
  394.     BOOL CreateFromBitmap(CBitmap* pBitmap, CPalette* pPal = NULL,
  395.         BOOL bTransferOwnership = TRUE);
  396. #endif // _WIN32_WCE_NO_PALETTE
  397.     BOOL CreateFromBitmap(HBITMAP hbm, HPALETTE hpal = NULL,
  398.         BOOL bTransferOwnership = FALSE);
  399.  
  400.     BOOL CreateFromMetafile(HMETAFILE hmf, int xExt, int yExt,
  401.         BOOL bTransferOwnership = FALSE);
  402.  
  403.     BOOL CreateFromIcon(UINT idResource);
  404.     BOOL CreateFromIcon(HICON hIcon, BOOL bTransferOwnership = FALSE);
  405.  
  406.     short GetType();
  407.     BOOL GetDisplayString(CString& strValue);
  408.     LPPICTUREDISP GetPictureDispatch();
  409.     void SetPictureDispatch(LPPICTUREDISP pDisp);
  410.     void Render(CDC* pDC, const CRect& rcRender, const CRect& rcWBounds);
  411.  
  412. // Implementation
  413. public:
  414.     ~CPictureHolder();
  415. };
  416.  
  417. /////////////////////////////////////////////////////////////////////////////
  418. // CDataPathProperty - Asynchonous properties for OLE Controls
  419.  
  420. #if !defined(_WIN32_WCE)
  421. class CDataPathProperty: public CAsyncMonikerFile
  422. {
  423.     DECLARE_DYNAMIC(CDataPathProperty)
  424. // Constructors
  425. public:
  426.     CDataPathProperty(COleControl* pControl = NULL);
  427.     CDataPathProperty(LPCTSTR lpszPath, COleControl* pControl = NULL);
  428.     // Calls SetPath(pControl) and SetPath(lpszPath) as appropriate.
  429.  
  430. // Attributes
  431. public:
  432.     void SetPath(LPCTSTR lpszPath);
  433.     // Sets the path to be opened by Open(COleControl*) and Open()
  434.     // lpszPath may be NULL.
  435.  
  436.     CString GetPath() const;
  437.     // Returns the current path setting.  Result may be empty.
  438.  
  439.     COleControl* GetControl();
  440.     // Returns a Pointer to the control.  Result may be NULL.
  441.  
  442.     void SetControl(COleControl* pControl);
  443.     // Sets the control which will be used with Open.  pControl may be NULL.
  444.  
  445. // Operations
  446. public:
  447.     // Overloads of Open takings some or all of: a path, a control,
  448.     // and a CFileException
  449.     // Overloads taking a COleControl call SetControl(pControl)
  450.     // Overloads taking an LPCTSTR cal SetPath(lpszPath)
  451.     virtual BOOL Open(COleControl* pControl, CFileException* pError = NULL);
  452.     virtual BOOL Open(LPCTSTR lpszPath, COleControl* pControl,
  453.         CFileException* pError = NULL);
  454.     virtual BOOL Open(LPCTSTR lpszPath, CFileException* pError = NULL);
  455.     virtual BOOL Open(CFileException* pError = NULL);
  456.     // Attempts to obtain an IBindHost* from the control returned by
  457.     // GetControl(). Calls CAsyncMonikerFile::Open with the path returned by
  458.     // GetPath() and, if it was obtained, the IBindHost*.
  459.     // Returns TRUE if successful.
  460.  
  461. // Overridables
  462. public:
  463.     virtual void ResetData();
  464.     // Derived classes should overide this.
  465.  
  466. // Implementation
  467. public:
  468. #ifdef _DEBUG
  469.     virtual void AssertValid() const;
  470.     virtual void Dump(CDumpContext& dc) const;
  471. #endif
  472.  
  473. private:
  474.     COleControl* m_pControl;
  475.     CString m_strPath;
  476. };
  477.  
  478. /////////////////////////////////////////////////////////////////////////////
  479. // CCachedDataPathProperty - Cached asynchonous properties for OLE Controls
  480.  
  481. class CCachedDataPathProperty : public CDataPathProperty
  482. {
  483.     DECLARE_DYNAMIC(CCachedDataPathProperty)
  484. //Constructors
  485. public:
  486.     CCachedDataPathProperty(COleControl* pControl = NULL);
  487.     CCachedDataPathProperty(LPCTSTR lpszPath, COleControl* pControl = NULL);
  488.  
  489. // Attributes
  490. public:
  491.     CMemFile m_Cache;
  492.  
  493. // Implementation
  494. public:
  495.     virtual void OnDataAvailable(DWORD dwSize, DWORD bscfFlag);
  496.     virtual void Close();
  497.     virtual void ResetData();
  498. #ifdef _DEBUG
  499.     virtual void AssertValid() const;
  500.     virtual void Dump(CDumpContext& dc) const;
  501. #endif
  502. };
  503. #endif // _WIN32_WCE
  504.  
  505. /////////////////////////////////////////////////////////////////////////////
  506. // COleControl - base class for a control implemented in C++ with MFC
  507.  
  508. struct _AFXCTL_ADVISE_INFO;     // implementation class
  509. struct _AFXCTL_UIACTIVE_INFO;   // implementation class
  510.  
  511. class CControlRectTracker : public CRectTracker
  512. {
  513. // Implementation
  514. public:
  515.     CControlRectTracker(LPCRECT lpSrcRect, UINT nStyle) 
  516.         : CRectTracker(lpSrcRect, nStyle) { }
  517.     CRect m_rectClip;    // saves the original clipping rectangle
  518. };
  519.  
  520. #ifdef _AFXDLL
  521. class COleControl : public CWnd
  522. #else
  523. class AFX_NOVTABLE COleControl : public CWnd
  524. #endif
  525. {
  526.     DECLARE_DYNAMIC(COleControl)
  527.  
  528. // Constructors
  529. public:
  530.     COleControl();
  531.  
  532. // Operations
  533.  
  534.     // Initialization
  535.     void SetInitialSize(int cx, int cy);
  536.     void InitializeIIDs(const IID* piidPrimary, const IID* piidEvents);
  537.  
  538.     // Invalidating
  539.     void InvalidateControl(LPCRECT lpRect = NULL, BOOL bErase = TRUE);
  540.  
  541.     // Modified flag
  542.     BOOL IsModified();
  543.     void SetModifiedFlag(BOOL bModified = TRUE);
  544.  
  545.     // Drawing operations
  546.     void DoSuperclassPaint(CDC* pDC, const CRect& rcBounds);
  547.     BOOL IsOptimizedDraw();
  548.  
  549.     // Property exchange
  550.     BOOL ExchangeVersion(CPropExchange* pPX, DWORD dwVersionDefault,
  551.         BOOL bConvert = TRUE);
  552.     BOOL ExchangeExtent(CPropExchange* pPX);
  553.     void ExchangeStockProps(CPropExchange* pPX);
  554.     BOOL IsConvertingVBX();
  555.  
  556.     DWORD SerializeVersion(CArchive& ar, DWORD dwVersionDefault,
  557.         BOOL bConvert = TRUE);
  558.     void SerializeExtent(CArchive& ar);
  559.     void SerializeStockProps(CArchive& ar);
  560.  
  561.     void ResetVersion(DWORD dwVersionDefault);
  562.     void ResetStockProps();
  563.  
  564.     // Stock methods
  565.     void Refresh();
  566.     void DoClick();
  567.  
  568.     // Stock properties
  569.     short GetAppearance();
  570.     void SetAppearance(short);
  571.     OLE_COLOR GetBackColor();
  572.     void SetBackColor(OLE_COLOR);
  573.     short GetBorderStyle();
  574.     void SetBorderStyle(short);
  575.     BOOL GetEnabled();
  576.     void SetEnabled(BOOL);
  577.     CFontHolder& InternalGetFont();
  578.     LPFONTDISP GetFont();
  579.     void SetFont(LPFONTDISP);
  580.     OLE_COLOR GetForeColor();
  581.     void SetForeColor(OLE_COLOR);
  582.     OLE_HANDLE GetHwnd();
  583.     const CString& InternalGetText();
  584.     BSTR GetText();
  585.     void SetText(LPCTSTR);
  586.     long GetReadyState();
  587.     void InternalSetReadyState(long lNewReadyState);
  588.  
  589.     // Using colors
  590.     COLORREF TranslateColor(OLE_COLOR clrColor, HPALETTE hpal = NULL);
  591.  
  592.     // Using fonts
  593.     CFont* SelectStockFont(CDC* pDC);
  594.     CFont* SelectFontObject(CDC* pDC, CFontHolder& fontHolder);
  595.     void GetStockTextMetrics(LPTEXTMETRIC lptm);
  596.     void GetFontTextMetrics(LPTEXTMETRIC lptm, CFontHolder& fontHolder);
  597.  
  598.     // Client site access
  599.     LPOLECLIENTSITE GetClientSite();
  600.  
  601.     // Generic ambient property access
  602.     BOOL GetAmbientProperty(DISPID dispid, VARTYPE vtProp, void* pvProp);
  603.     BOOL WillAmbientsBeValidDuringLoad();
  604.  
  605.     // Specific ambient properties
  606.     short AmbientAppearance();
  607.     OLE_COLOR AmbientBackColor();
  608.     CString AmbientDisplayName();
  609.     LPFONTDISP AmbientFont();
  610.     OLE_COLOR AmbientForeColor();
  611.     LCID AmbientLocaleID();
  612.     CString AmbientScaleUnits();
  613.     short AmbientTextAlign();
  614.     BOOL AmbientUserMode();
  615.     BOOL AmbientUIDead();
  616.     BOOL AmbientShowGrabHandles();
  617.     BOOL AmbientShowHatching();
  618.  
  619.     // Firing events
  620.     void AFX_CDECL FireEvent(DISPID dispid, BYTE* pbParams, ...);
  621.  
  622.     // Firing functions for stock events
  623.     void FireKeyDown(USHORT* pnChar, short nShiftState);
  624.     void FireKeyUp(USHORT* pnChar, short nShiftState);
  625.     void FireKeyPress(USHORT* pnChar);
  626.     void FireMouseDown(short nButton, short nShiftState,
  627.         OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
  628.     void FireMouseUp(short nButton, short nShiftState,
  629.         OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
  630.     void FireMouseMove(short nButton, short nShiftState,
  631.         OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
  632.     void FireClick();
  633.     void FireDblClick();
  634.     void FireError(SCODE scode, LPCTSTR lpszDescription, UINT nHelpID = 0);
  635.     void FireReadyStateChange();
  636.  
  637.     // Changing size and/or rectangle
  638.     BOOL GetRectInContainer(LPRECT lpRect);
  639.     BOOL SetRectInContainer(LPCRECT lpRect);
  640.     void GetControlSize(int* pcx, int* pcy);
  641.     BOOL SetControlSize(int cx, int cy);
  642.  
  643.     // Window management
  644.     void RecreateControlWindow();
  645.  
  646.     // Modal dialog operations
  647.     void PreModalDialog(HWND hWndParent = NULL);
  648.     void PostModalDialog(HWND hWndParent = NULL);
  649.  
  650.     // Data binding operations
  651.     void BoundPropertyChanged(DISPID dispid);
  652.     BOOL BoundPropertyRequestEdit(DISPID dispid);
  653.  
  654.     // Dispatch exceptions
  655.     void ThrowError(SCODE sc, UINT nDescriptionID, UINT nHelpID = -1);
  656.     void ThrowError(SCODE sc, LPCTSTR pszDescription = NULL, UINT nHelpID = 0);
  657.     void GetNotSupported();
  658.     void SetNotSupported();
  659.     void SetNotPermitted();
  660.  
  661.     // Communication with the control site
  662.     void ControlInfoChanged();
  663.     BOOL LockInPlaceActive(BOOL bLock);
  664.     LPDISPATCH GetExtendedControl();
  665.     void TransformCoords(POINTL* lpptlHimetric,
  666.         POINTF* lpptfContainer, DWORD flags);
  667.  
  668.     // Simple frame
  669.     void EnableSimpleFrame();
  670.  
  671.     // Windowless operations
  672.     CWnd* SetCapture();
  673.     BOOL ReleaseCapture();
  674.     CWnd* GetCapture();
  675.     CWnd* SetFocus();
  676.     CWnd* GetFocus();
  677.     CDC* GetDC(LPCRECT lprcRect = NULL, DWORD dwFlags = OLEDC_PAINTBKGND);
  678.     int ReleaseDC(CDC* pDC);
  679.     void InvalidateRgn(CRgn* pRgn, BOOL bErase = TRUE);
  680.     void ScrollWindow(int xAmount, int yAmount, LPCRECT lpRect = NULL,
  681.         LPCRECT lpClipRect = NULL);
  682.     BOOL ClipCaretRect(LPRECT lpRect);
  683.     virtual void GetClientRect(LPRECT lpRect) const;
  684.  
  685. // Overridables
  686.     virtual void DoPropExchange(CPropExchange* pPX);
  687.     virtual void OnResetState();
  688.     virtual void OnDraw(
  689.                 CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid);
  690.     virtual void OnDrawMetafile(CDC* pDC, const CRect& rcBounds);
  691.  
  692.     // Class ID (implemented by IMPLEMENT_OLECREATE_EX macro)
  693.     virtual HRESULT GetClassID(LPCLSID pclsid) = 0;
  694.  
  695.     // For customizing the default messages on the status bar
  696.     virtual void GetMessageString(UINT nID, CString& rMessage) const;
  697.  
  698.     // Display of error events to user
  699.     virtual void DisplayError(SCODE scode, LPCTSTR lpszDescription,
  700.         LPCTSTR lpszSource, LPCTSTR lpszHelpFile, UINT nHelpID);
  701.  
  702.     // IOleObject notifications
  703.     virtual void OnSetClientSite();
  704.     virtual BOOL OnSetExtent(LPSIZEL lpSizeL);
  705.     virtual void OnClose(DWORD dwSaveOption);
  706.  
  707.     // IOleInPlaceObject notifications
  708.     virtual BOOL OnSetObjectRects(LPCRECT lpRectPos, LPCRECT lpRectClip);
  709.  
  710.     // Event connection point notifications
  711.     virtual void OnEventAdvise(BOOL bAdvise);
  712.  
  713.     // Override to hook firing of Click event
  714.     virtual void OnClick(USHORT iButton);
  715.  
  716.     // Override to get character after key events have been processed.
  717.     virtual void OnKeyDownEvent(USHORT nChar, USHORT nShiftState);
  718.     virtual void OnKeyUpEvent(USHORT nChar, USHORT nShiftState);
  719.     virtual void OnKeyPressEvent(USHORT nChar);
  720.  
  721.     // Change notifications
  722.     virtual void OnAppearanceChanged();
  723.     virtual void OnBackColorChanged();
  724.     virtual void OnBorderStyleChanged();
  725.     virtual void OnEnabledChanged();
  726.     virtual void OnTextChanged();
  727.     virtual void OnFontChanged();
  728.     virtual void OnForeColorChanged();
  729.  
  730.     // IOleControl notifications
  731.     virtual void OnGetControlInfo(LPCONTROLINFO pControlInfo);
  732.     virtual void OnMnemonic(LPMSG pMsg);
  733.     virtual void OnAmbientPropertyChange(DISPID dispid);
  734.     virtual void OnFreezeEvents(BOOL bFreeze);
  735.  
  736. #if !defined(_WIN32_WCE)
  737.     // In-place activation
  738.     virtual HMENU OnGetInPlaceMenu();
  739.     virtual void OnShowToolBars();
  740.     virtual void OnHideToolBars();
  741. #endif // _WIN32_WCE
  742.  
  743.     // IViewObject
  744.     virtual BOOL OnGetColorSet(DVTARGETDEVICE* ptd, HDC hicTargetDev,
  745.                 LPLOGPALETTE* ppColorSet);
  746.     virtual BOOL OnGetViewExtent(DWORD dwDrawAspect, LONG lindex,
  747.         DVTARGETDEVICE* ptd, LPSIZEL lpsizel);
  748.     virtual BOOL OnGetViewRect(DWORD dwAspect, LPRECTL pRect);
  749.     virtual DWORD OnGetViewStatus();
  750.     virtual BOOL OnQueryHitPoint(DWORD dwAspect, LPCRECT pRectBounds,
  751.         POINT ptlLoc, LONG lCloseHint, DWORD* pHitResult);
  752.     virtual BOOL OnQueryHitRect(DWORD dwAspect, LPCRECT pRectBounds,
  753.         LPCRECT prcLoc, LONG lCloseHint, DWORD* pHitResult);
  754.     virtual BOOL OnGetNaturalExtent(DWORD dwAspect, LONG lindex,
  755.         DVTARGETDEVICE* ptd, HDC hicTargetDev, DVEXTENTINFO* pExtentInfo,
  756.         LPSIZEL psizel);
  757.  
  758.     // IDataObject - see COleDataSource for a description of these overridables
  759.     virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
  760.     virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
  761.     virtual BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
  762.     virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium,
  763.         BOOL bRelease);
  764.  
  765.     // Verbs
  766.     virtual BOOL OnEnumVerbs(LPENUMOLEVERB* ppenumOleVerb);
  767.     virtual BOOL OnDoVerb(LONG iVerb, LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect);
  768.     virtual BOOL OnEdit(LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect);
  769.     virtual BOOL OnProperties(LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect);
  770.  
  771.     // IPerPropertyBrowsing overrides
  772.     virtual BOOL OnGetDisplayString(DISPID dispid, CString& strValue);
  773.     virtual BOOL OnMapPropertyToPage(DISPID dispid, LPCLSID lpclsid,
  774.         BOOL* pbPageOptional);
  775.     virtual BOOL OnGetPredefinedStrings(DISPID dispid,
  776.         CStringArray* pStringArray, CDWordArray* pCookieArray);
  777.     virtual BOOL OnGetPredefinedValue(DISPID dispid, DWORD dwCookie,
  778.         VARIANT* lpvarOut);
  779.  
  780.     // Subclassing
  781.     virtual BOOL IsSubclassedControl();
  782.  
  783.     // Window reparenting
  784.     virtual void ReparentControlWindow(HWND hWndOuter, HWND hWndParent);
  785.  
  786.     // Window procedure
  787.     virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  788.  
  789.     // General-purpose flags
  790.     enum ControlFlags {
  791.         fastBeginPaint      = 0x0001,
  792.         clipPaintDC         = 0x0002,
  793.         pointerInactive     = 0x0004,
  794.         noFlickerActivate   = 0x0008,
  795.         windowlessActivate  = 0x0010,
  796.         canOptimizeDraw     = 0x0020,
  797.     };
  798.     virtual DWORD GetControlFlags();
  799.  
  800.     // Inactive pointer handling
  801.     virtual DWORD GetActivationPolicy();
  802. #if !defined(_WIN32_WCE_NO_CURSOR)
  803.     virtual BOOL OnInactiveSetCursor(LPCRECT lprcBounds, long x, long y,
  804.         DWORD dwMouseMsg, BOOL bSetAlways);
  805. #endif // _WIN32_WCE_NO_CURSOR
  806.     virtual void OnInactiveMouseMove(LPCRECT lprcBounds, long x, long y,
  807.         DWORD dwKeyState);
  808.  
  809.     // Windowless activation handling
  810.     virtual BOOL OnWindowlessMessage(UINT msg, WPARAM wParam, LPARAM lParam,
  811.         LRESULT* plResult);
  812.     virtual IDropTarget* GetWindowlessDropTarget();
  813.  
  814.     // Inactive/windowless helper functions
  815.     virtual void GetClientOffset(long* pdxOffset, long* pdyOffset) const;
  816.     virtual UINT ParentToClient(LPCRECT lprcBounds, LPPOINT pPoint,
  817.         BOOL bHitTest = FALSE) const;
  818.     virtual void ClientToParent(LPCRECT lprcBounds, LPPOINT pPoint) const;
  819.  
  820.     // Asynchronous properties
  821.     void Load(LPCTSTR strNewPath, CDataPathProperty& prop);
  822.  
  823. // Implementation
  824. public:
  825.     ~COleControl();
  826.     void RequestAsynchronousExchange(DWORD dwVersion);
  827.  
  828. #ifdef _DEBUG
  829.     void AssertValid() const;
  830.     void Dump(CDumpContext& dc) const;
  831. #endif // _DEBUG
  832.  
  833. protected:
  834.     // Friend classes
  835.     friend class COleControlInnerUnknown;
  836.     friend class CReflectorWnd;
  837.     friend class CControlFrameWnd;
  838.  
  839.     // Interface hook for primary automation interface
  840.     LPUNKNOWN GetInterfaceHook(const void* piid);
  841.  
  842.     // Shutdown
  843.     virtual void OnFinalRelease();
  844.     void ReleaseCaches();
  845.  
  846.     // Window management
  847.     virtual BOOL CreateControlWindow(HWND hWndParent, const CRect& rcPos,
  848.         LPCRECT prcClipped = NULL);
  849.     void CreateWindowForSubclassedControl();
  850.     BOOL IgnoreWindowMessage(UINT msg, WPARAM wParam, LPARAM lParam,
  851.         LRESULT* plResult);
  852.     virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam);
  853.  
  854.     // Serialization
  855.     HRESULT SaveState(IStream* pStm);
  856.     HRESULT LoadState(IStream* pStm);
  857.     virtual void Serialize(CArchive& ar);
  858.  
  859.     // Drawing
  860.     void DrawContent(CDC* pDC, CRect& rc);
  861.     void DrawMetafile(CDC* pDC, CRect& rc);
  862. WCE_DEL    BOOL GetMetafileData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
  863.  
  864.     // Implementation of IDataObject
  865.     // CControlDataSource implements OnRender reflections to COleControl
  866.     class CControlDataSource : public COleDataSource
  867.     {
  868.     public:
  869.         CControlDataSource(COleControl* pCtrl);
  870.     protected:
  871.         virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
  872.         virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
  873.         virtual BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
  874.         virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium,
  875.             BOOL bRelease);
  876.         COleControl* m_pCtrl;
  877.     };
  878.     friend class CControlDataSource;
  879.  
  880.     // IDataObject formats
  881.     CControlDataSource* GetDataSource();
  882.     virtual void SetInitialDataFormats();
  883.     BOOL GetPropsetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium,
  884.         REFCLSID fmtid);
  885.     BOOL SetPropsetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium,
  886.         REFCLSID fmtid);
  887.  
  888.     // Type library
  889.     BOOL GetDispatchIID(IID* pIID);
  890.  
  891.     // Connection point container
  892.     virtual LPCONNECTIONPOINT GetConnectionHook(REFIID iid);
  893.     virtual BOOL GetExtraConnectionPoints(CPtrArray* pConnPoints);
  894.  
  895.     // Events
  896.     static const AFX_DATA AFX_EVENTMAP_ENTRY _eventEntries[];
  897.     virtual const AFX_EVENTMAP* GetEventMap() const;
  898.     static const AFX_DATA AFX_EVENTMAP eventMap;
  899.     const AFX_EVENTMAP_ENTRY* GetEventMapEntry(LPCTSTR pszName,
  900.         DISPID* pDispid) const;
  901.     void FireEventV(DISPID dispid, BYTE* pbParams, va_list argList);
  902.  
  903.     // Stock events
  904.     void KeyDown(USHORT* pnChar);
  905.     void KeyUp(USHORT* pnChar);
  906.     void ButtonDown(USHORT iButton, UINT nFlags, CPoint point);
  907.     void ButtonUp(USHORT iButton, UINT nFlags, CPoint point);
  908.     void ButtonDblClk(USHORT iButton, UINT nFlags, CPoint point);
  909.  
  910.     // Masks to identify which stock events and properties are used
  911.     void InitStockEventMask();
  912.     void InitStockPropMask();
  913.     DWORD GetStockEventMask() const;
  914.     DWORD GetStockPropMask() const;
  915.  
  916.     // Support for subclassing a Windows control
  917.     CWnd* GetOuterWindow() const;       // m_pReflect if any, otherwise this
  918.     virtual void OnReflectorDestroyed();
  919.  
  920.     // Aggregation of default handler
  921.     virtual BOOL OnCreateAggregates();
  922. WCE_DEL    LPVOID QueryDefHandler(REFIID iid);
  923.  
  924.     // State change notifications
  925.     void SendAdvise(UINT uCode);
  926.  
  927.     // Non-in-place activation
  928.     virtual HRESULT OnOpen(BOOL bTryInPlace, LPMSG pMsg);
  929. #ifdef _AFXDLL
  930.     void ResizeOpenControl(int cx, int cy);
  931.     virtual CControlFrameWnd* CreateFrameWindow();
  932.     virtual void ResizeFrameWindow(int cx, int cy);
  933.     virtual void OnFrameClose();
  934. #endif
  935.     virtual HRESULT OnHide();
  936.  
  937.     // In-place activation
  938.     virtual HRESULT OnActivateInPlace(BOOL bUIActivate, LPMSG pMsg);
  939.     void ForwardActivationMsg(LPMSG pMsg);
  940. WCE_DEL    virtual void AddFrameLevelUI();
  941. WCE_DEL    virtual void RemoveFrameLevelUI();
  942. WCE_DEL    virtual BOOL BuildSharedMenu();
  943. WCE_DEL    virtual void DestroySharedMenu();
  944.  
  945.     // Property sheet
  946.     virtual LPCLSID GetPropPageIDs(ULONG& cPropPages);
  947.  
  948.     // IOleObject implementation
  949.     void GetUserType(LPTSTR pszUserType);
  950.     virtual UINT GetUserTypeNameID() = 0;
  951.     virtual DWORD GetMiscStatus() = 0;
  952.  
  953.     // Rectangle tracker
  954.     void CreateTracker(BOOL bHandles, BOOL bHatching);
  955.     void CreateTracker(BOOL bHandles, BOOL bHatching, LPCRECT prcClip);
  956.     void DestroyTracker();
  957.  
  958.     // Automation
  959.     BOOL IsInvokeAllowed(DISPID dispid);
  960.  
  961.     // Ambient property interface initialization
  962.     COleDispatchDriver* GetAmbientDispatchDriver();
  963.  
  964.     // Data members
  965.     const IID* m_piidPrimary;           // IID for control automation
  966.     const IID* m_piidEvents;            // IID for control events
  967.     DWORD m_dwVersionLoaded;            // Version number of loaded state
  968.     COleDispatchDriver m_ambientDispDriver; // Driver for ambient properties
  969.     ULONG m_cEventsFrozen;              // Event freeze count (>0 means frozen)
  970.     union
  971.     {
  972. #ifdef _AFXDLL
  973.         CControlFrameWnd* m_pWndOpenFrame;  // Open frame window.
  974. #endif
  975.         CControlRectTracker* m_pRectTracker;       // Tracker for UI active control
  976.     };
  977.     CRect m_rcPos;                      // Control's position rectangle
  978.     CRect m_rcBounds;                   // Bounding rectangle for drawing
  979.     CPoint m_ptOffset;                  // Child window origin
  980.     long m_cxExtent;                    // Control's width in HIMETRIC units
  981.     long m_cyExtent;                    // Control's height in HIMETRIC units
  982.     class CReflectorWnd* m_pReflect;    // Reflector window
  983.     UINT m_nIDTracking;                 // Tracking command ID or string IDS
  984.     UINT m_nIDLastMessage;              // Last displayed message string IDS
  985.     unsigned m_bAutoMenuEnable : 1;     // Disable menu items without handlers?
  986.     unsigned m_bFinalReleaseCalled : 1; // Are we handling the final Release?
  987.     unsigned m_bModified : 1;           // "Dirty" bit.
  988.     unsigned m_bCountOnAmbients : 1;    // Can we count on Ambients during load?
  989.     unsigned m_iButtonState : 3;        // Which buttons are down?
  990.     unsigned m_iDblClkState : 3;        // Which buttons involved in dbl click?
  991.     unsigned m_bInPlaceActive : 1;      // Are we in-place active?
  992.     unsigned m_bUIActive : 1;           // Are we UI active?
  993.     unsigned m_bPendingUIActivation : 1; // Are we about to become UI active?
  994. #ifdef _AFXDLL
  995.     unsigned m_bOpen : 1;               // Are we open (non-in-place)?
  996. #endif
  997.     unsigned m_bChangingExtent : 1;     // Extent is currently being changed
  998.     unsigned m_bConvertVBX : 1;         // VBX conversion in progress
  999.     unsigned m_bSimpleFrame : 1;        // Simple frame support
  1000.     unsigned m_bUIDead : 1;             // UIDead ambient property value
  1001.     unsigned m_bInitialized : 1;        // Was IPersist*::{InitNew,Load} called?
  1002.     unsigned m_bAutoClip : 1;           // Does container automatically clip?
  1003.     unsigned m_bMsgReflect : 1;         // Does container reflect messages?
  1004.     unsigned m_bInPlaceSiteEx : 1;      // Extended in-place site?
  1005.     unsigned m_bInPlaceSiteWndless : 1; // Windowless in-place site?
  1006.     unsigned m_bNoRedraw : 1;           // Should we skip OnPaint this time?
  1007.     unsigned m_bOptimizedDraw : 1;      // Is optimized drawing possible?
  1008.  
  1009.     // Stock properties
  1010.     OLE_COLOR m_clrBackColor;           // BackColor
  1011.     OLE_COLOR m_clrForeColor;           // ForeColor
  1012.     CString m_strText;                  // Text/Caption
  1013.     CFontHolder m_font;                 // Font
  1014.     HFONT m_hFontPrev;                  // Previously selected font object
  1015.     short m_sAppearance;                // Appearance
  1016.     short m_sBorderStyle;               // BorderStyle
  1017.     BOOL m_bEnabled;                    // Enabled
  1018.     long m_lReadyState;                 // ReadyState
  1019.  
  1020.     // UI Active info (shared OLE menu data)
  1021.     _AFXCTL_UIACTIVE_INFO* m_pUIActiveInfo;
  1022.  
  1023.     // Default Handler aggregation
  1024.     LPUNKNOWN m_pDefIUnknown;
  1025.     _AFXCTL_ADVISE_INFO* m_pAdviseInfo;
  1026.     LPPERSISTSTORAGE m_pDefIPersistStorage;
  1027.     LPVIEWOBJECT m_pDefIViewObject;
  1028.     LPOLECACHE m_pDefIOleCache;
  1029.  
  1030.     // OLE client site interfaces
  1031.     LPOLECLIENTSITE m_pClientSite;          // Client site
  1032.     union
  1033.     {
  1034.         LPOLEINPLACESITE m_pInPlaceSite;    // In-place site
  1035.         LPOLEINPLACESITEEX m_pInPlaceSiteEx;
  1036.         LPOLEINPLACESITEWINDOWLESS m_pInPlaceSiteWndless;
  1037.     };
  1038.     LPOLECONTROLSITE m_pControlSite;        // Control site
  1039.     LPOLEADVISEHOLDER m_pOleAdviseHolder;   // Advise holder
  1040.     LPDATAADVISEHOLDER m_pDataAdviseHolder; // Data advise holder
  1041.     LPSIMPLEFRAMESITE m_pSimpleFrameSite;   // Simple frame site
  1042.  
  1043.     // OLE in-place activation info
  1044.     LPOLEINPLACEFRAME m_pInPlaceFrame;
  1045.     OLEINPLACEFRAMEINFO m_frameInfo;
  1046.     LPOLEINPLACEUIWINDOW m_pInPlaceDoc;
  1047.  
  1048.     // OLE data source
  1049.     CControlDataSource* m_pDataSource;
  1050.  
  1051.     // OLE data path load data
  1052.     BOOL m_bDataPathPropertiesLoaded;
  1053.     DWORD m_dwDataPathVersionToReport;
  1054.  
  1055. // Message Maps
  1056. protected:
  1057.     //{{AFX_MSG(COleControl)
  1058.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  1059.     afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  1060.     afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  1061.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  1062.     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  1063.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  1064.     afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  1065.     afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
  1066.     afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
  1067.     afx_msg void OnMButtonDblClk(UINT nFlags, CPoint point);
  1068.     afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  1069.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  1070.     afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
  1071.     afx_msg void OnInitMenuPopup(CMenu*, UINT, BOOL);
  1072.     afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  1073.     afx_msg LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
  1074.     afx_msg void OnEnterIdle(UINT nWhy, CWnd* pWho);
  1075.     afx_msg void OnCancelMode();
  1076.     afx_msg void OnPaint(CDC* pDC);
  1077.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  1078.     afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  1079.     afx_msg void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  1080. WCE_DEL    afx_msg int  OnMouseActivate(CWnd *pDesktopWnd, UINT nHitTest, UINT message);
  1081.     afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
  1082. WCE_DEL afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
  1083.     afx_msg void OnDestroy();
  1084.     afx_msg  void OnKillFocus(CWnd* pNewWnd);
  1085.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  1086.     afx_msg void OnNcPaint();
  1087. WCE_DEL    afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp);
  1088. WCE_DEL    afx_msg UINT OnNcHitTest(CPoint point);
  1089. WCE_DEL    afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
  1090. #if !defined(_WIN32_WCE_NO_CURSOR)
  1091.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  1092. #endif // _WIN32_WCE_NO_CURSOR
  1093.     afx_msg UINT OnGetDlgCode();
  1094.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  1095.     afx_msg void OnSize(UINT nType, int cx, int cy);
  1096.     afx_msg void OnMove(int x, int y);
  1097.     afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  1098.     //}}AFX_MSG
  1099.  
  1100.     afx_msg LRESULT OnOcmCtlColorBtn(WPARAM wParam, LPARAM lParam);
  1101.     afx_msg LRESULT OnOcmCtlColorDlg(WPARAM wParam, LPARAM lParam);
  1102.     afx_msg LRESULT OnOcmCtlColorEdit(WPARAM wParam, LPARAM lParam);
  1103.     afx_msg LRESULT OnOcmCtlColorListBox(WPARAM wParam, LPARAM lParam);
  1104.     afx_msg LRESULT OnOcmCtlColorMsgBox(WPARAM wParam, LPARAM lParam);
  1105.     afx_msg LRESULT OnOcmCtlColorScrollBar(WPARAM wParam, LPARAM lParam);
  1106.     afx_msg LRESULT OnOcmCtlColorStatic(WPARAM wParam, LPARAM lParam);
  1107.  
  1108.     DECLARE_MESSAGE_MAP()
  1109.  
  1110.     // button handler helpers
  1111.     void OnButtonUp(USHORT nButton, UINT nFlags, CPoint point);
  1112.     void OnButtonDown(USHORT nButton, UINT nFlags, CPoint point);
  1113.     void OnButtonDblClk(USHORT nButton, UINT nFlags, CPoint point);
  1114.  
  1115. // Interface Maps
  1116. public:
  1117.     // IPersistStorage
  1118.     BEGIN_INTERFACE_PART(PersistStorage, IPersistStorage)
  1119.         INIT_INTERFACE_PART(COleControl, PersistStorage)
  1120.         STDMETHOD(GetClassID)(LPCLSID);
  1121.         STDMETHOD(IsDirty)();
  1122.         STDMETHOD(InitNew)(LPSTORAGE);
  1123.         STDMETHOD(Load)(LPSTORAGE);
  1124.         STDMETHOD(Save)(LPSTORAGE, BOOL);
  1125.         STDMETHOD(SaveCompleted)(LPSTORAGE);
  1126.         STDMETHOD(HandsOffStorage)();
  1127.     END_INTERFACE_PART_STATIC(PersistStorage)
  1128.  
  1129.     // IPersistStreamInit
  1130.     BEGIN_INTERFACE_PART(PersistStreamInit, IPersistStreamInit)
  1131.         INIT_INTERFACE_PART(COleControl, PersistStreamInit)
  1132.         STDMETHOD(GetClassID)(LPCLSID);
  1133.         STDMETHOD(IsDirty)();
  1134.         STDMETHOD(Load)(LPSTREAM);
  1135.         STDMETHOD(Save)(LPSTREAM, BOOL);
  1136.         STDMETHOD(GetSizeMax)(ULARGE_INTEGER *);
  1137.         STDMETHOD(InitNew)();
  1138.     END_INTERFACE_PART_STATIC(PersistStreamInit)
  1139.  
  1140.     // IPersistMemory
  1141.     BEGIN_INTERFACE_PART(PersistMemory, IPersistMemory)
  1142.         INIT_INTERFACE_PART(COleControl, PersistMemory)
  1143.         STDMETHOD(GetClassID)(LPCLSID);
  1144.         STDMETHOD(IsDirty)();
  1145.         STDMETHOD(Load)(LPVOID, ULONG);
  1146.         STDMETHOD(Save)(LPVOID, BOOL, ULONG);
  1147.         STDMETHOD(GetSizeMax)(ULONG*);
  1148.         STDMETHOD(InitNew)();
  1149.     END_INTERFACE_PART_STATIC(PersistMemory)
  1150.  
  1151.     // IPersistPropertyBag
  1152.     BEGIN_INTERFACE_PART(PersistPropertyBag, IPersistPropertyBag)
  1153.         INIT_INTERFACE_PART(COleControl, PersistPropertyBag)
  1154.         STDMETHOD(GetClassID)(LPCLSID);
  1155.         STDMETHOD(InitNew)();
  1156.         STDMETHOD(Load)(LPPROPERTYBAG, LPERRORLOG);
  1157.         STDMETHOD(Save)(LPPROPERTYBAG, BOOL, BOOL);
  1158.     END_INTERFACE_PART_STATIC(PersistPropertyBag)
  1159.  
  1160.     // IOleObject
  1161.     BEGIN_INTERFACE_PART(OleObject, IOleObject)
  1162.         INIT_INTERFACE_PART(COleControl, OleObject)
  1163.         STDMETHOD(SetClientSite)(LPOLECLIENTSITE);
  1164.         STDMETHOD(GetClientSite)(LPOLECLIENTSITE*);
  1165.         STDMETHOD(SetHostNames)(LPCOLESTR, LPCOLESTR);
  1166.         STDMETHOD(Close)(DWORD);
  1167.         STDMETHOD(SetMoniker)(DWORD, LPMONIKER);
  1168.         STDMETHOD(GetMoniker)(DWORD, DWORD, LPMONIKER*);
  1169.         STDMETHOD(InitFromData)(LPDATAOBJECT, BOOL, DWORD);
  1170.         STDMETHOD(GetClipboardData)(DWORD, LPDATAOBJECT*);
  1171.         STDMETHOD(DoVerb)(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
  1172.         STDMETHOD(EnumVerbs)(IEnumOLEVERB**);
  1173.         STDMETHOD(Update)();
  1174.         STDMETHOD(IsUpToDate)();
  1175.         STDMETHOD(GetUserClassID)(CLSID*);
  1176.         STDMETHOD(GetUserType)(DWORD, LPOLESTR*);
  1177.         STDMETHOD(SetExtent)(DWORD, LPSIZEL);
  1178.         STDMETHOD(GetExtent)(DWORD, LPSIZEL);
  1179.         STDMETHOD(Advise)(LPADVISESINK, LPDWORD);
  1180.         STDMETHOD(Unadvise)(DWORD);
  1181.         STDMETHOD(EnumAdvise)(LPENUMSTATDATA*);
  1182.         STDMETHOD(GetMiscStatus)(DWORD, LPDWORD);
  1183.         STDMETHOD(SetColorScheme)(LPLOGPALETTE);
  1184.     END_INTERFACE_PART(OleObject)
  1185.  
  1186.     // IViewObjectEx
  1187.     BEGIN_INTERFACE_PART(ViewObject, IViewObjectEx)
  1188.         INIT_INTERFACE_PART(COleControl, ViewObject)
  1189.         STDMETHOD(Draw)(DWORD, LONG, void*, DVTARGETDEVICE*, HDC, HDC,
  1190.             LPCRECTL, LPCRECTL, BOOL (CALLBACK*)(DWORD), DWORD);
  1191.         STDMETHOD(GetColorSet)(DWORD, LONG, void*, DVTARGETDEVICE*,
  1192.             HDC, LPLOGPALETTE*);
  1193.         STDMETHOD(Freeze)(DWORD, LONG, void*, DWORD*);
  1194.         STDMETHOD(Unfreeze)(DWORD);
  1195.         STDMETHOD(SetAdvise)(DWORD, DWORD, LPADVISESINK);
  1196.         STDMETHOD(GetAdvise)(DWORD*, DWORD*, LPADVISESINK*);
  1197.         STDMETHOD(GetExtent) (DWORD, LONG, DVTARGETDEVICE*, LPSIZEL);
  1198.         STDMETHOD(GetRect)(DWORD, LPRECTL);
  1199.         STDMETHOD(GetViewStatus)(DWORD*);
  1200.         STDMETHOD(QueryHitPoint)(DWORD, LPCRECT, POINT, LONG, DWORD*);
  1201.         STDMETHOD(QueryHitRect)(DWORD, LPCRECT, LPCRECT, LONG, DWORD*);
  1202.         STDMETHOD(GetNaturalExtent)(DWORD, LONG, DVTARGETDEVICE*, HDC,
  1203.             DVEXTENTINFO*, LPSIZEL);
  1204.     END_INTERFACE_PART(ViewObject)
  1205.  
  1206.     // IDataObject
  1207. #if !defined(_WIN32_WCE)
  1208.     BEGIN_INTERFACE_PART(DataObject, IDataObject)
  1209.         INIT_INTERFACE_PART(COleControl, DataObject)
  1210.         STDMETHOD(GetData)(LPFORMATETC, LPSTGMEDIUM);
  1211.         STDMETHOD(GetDataHere)(LPFORMATETC, LPSTGMEDIUM);
  1212.         STDMETHOD(QueryGetData)(LPFORMATETC);
  1213.         STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC, LPFORMATETC);
  1214.         STDMETHOD(SetData)(LPFORMATETC, LPSTGMEDIUM, BOOL);
  1215.         STDMETHOD(EnumFormatEtc)(DWORD, LPENUMFORMATETC*);
  1216.         STDMETHOD(DAdvise)(LPFORMATETC, DWORD, LPADVISESINK, LPDWORD);
  1217.         STDMETHOD(DUnadvise)(DWORD);
  1218.         STDMETHOD(EnumDAdvise)(LPENUMSTATDATA*);
  1219.     END_INTERFACE_PART_STATIC(DataObject)
  1220. #endif // _WIN32_WCE
  1221.  
  1222.     // IOleInPlaceObject
  1223.     BEGIN_INTERFACE_PART(OleInPlaceObject, IOleInPlaceObjectWindowless)
  1224.         INIT_INTERFACE_PART(COleControl, OleInPlaceObject)
  1225.         STDMETHOD(GetWindow)(HWND*);
  1226.         STDMETHOD(ContextSensitiveHelp)(BOOL);
  1227.         STDMETHOD(InPlaceDeactivate)();
  1228.         STDMETHOD(UIDeactivate)();
  1229.         STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT);
  1230.         STDMETHOD(ReactivateAndUndo)();
  1231.         STDMETHOD(OnWindowMessage)(UINT msg, WPARAM wParam, LPARAM lparam,
  1232.             LRESULT* plResult);
  1233.         STDMETHOD(GetDropTarget)(IDropTarget **ppDropTarget);
  1234.     END_INTERFACE_PART(OleInPlaceObject)
  1235.  
  1236.     // IOleInPlaceActiveObject
  1237.     BEGIN_INTERFACE_PART(OleInPlaceActiveObject, IOleInPlaceActiveObject)
  1238.         INIT_INTERFACE_PART(COleControl, OleInPlaceActiveObject)
  1239.         STDMETHOD(GetWindow)(HWND*);
  1240.         STDMETHOD(ContextSensitiveHelp)(BOOL);
  1241.         STDMETHOD(TranslateAccelerator)(LPMSG);
  1242.         STDMETHOD(OnFrameWindowActivate)(BOOL);
  1243.         STDMETHOD(OnDocWindowActivate)(BOOL);
  1244.         STDMETHOD(ResizeBorder)(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL);
  1245.         STDMETHOD(EnableModeless)(BOOL);
  1246.     END_INTERFACE_PART(OleInPlaceActiveObject)
  1247.  
  1248.     // IOleCache
  1249. #if !defined(_WIN32_WCE)
  1250.     BEGIN_INTERFACE_PART(OleCache, IOleCache)
  1251.         INIT_INTERFACE_PART(COleControl, OleCache)
  1252.         STDMETHOD(Cache)(LPFORMATETC, DWORD, LPDWORD);
  1253.         STDMETHOD(Uncache)(DWORD);
  1254.         STDMETHOD(EnumCache)(LPENUMSTATDATA*);
  1255.         STDMETHOD(InitCache)(LPDATAOBJECT);
  1256.         STDMETHOD(SetData)(LPFORMATETC, STGMEDIUM*, BOOL);
  1257.     END_INTERFACE_PART_STATIC(OleCache)
  1258. #endif // _WIN32_WCE
  1259.  
  1260.     // IOleControl
  1261.     BEGIN_INTERFACE_PART(OleControl, IOleControl)
  1262.         INIT_INTERFACE_PART(COleControl, OleControl)
  1263.         STDMETHOD(GetControlInfo)(LPCONTROLINFO pCI);
  1264.         STDMETHOD(OnMnemonic)(LPMSG pMsg);
  1265.         STDMETHOD(OnAmbientPropertyChange)(DISPID dispid);
  1266.         STDMETHOD(FreezeEvents)(BOOL bFreeze);
  1267.     END_INTERFACE_PART(OleControl)
  1268.  
  1269.     // IProvideClassInfo2
  1270.     BEGIN_INTERFACE_PART(ProvideClassInfo, IProvideClassInfo2)
  1271.         INIT_INTERFACE_PART(COleControl, ProvideClassInfo)
  1272.         STDMETHOD(GetClassInfo)(LPTYPEINFO* ppTypeInfo);
  1273.         STDMETHOD(GetGUID)(DWORD dwGuidKind, GUID* pGUID);
  1274.     END_INTERFACE_PART_STATIC(ProvideClassInfo)
  1275.  
  1276.     // ISpecifyPropertyPages
  1277.     BEGIN_INTERFACE_PART(SpecifyPropertyPages, ISpecifyPropertyPages)
  1278.         INIT_INTERFACE_PART(COleControl, SpecifyPropertyPages)
  1279.         STDMETHOD(GetPages)(CAUUID*);
  1280.     END_INTERFACE_PART_STATIC(SpecifyPropertyPages)
  1281.  
  1282.     // IPerPropertyBrowsing
  1283.     BEGIN_INTERFACE_PART(PerPropertyBrowsing, IPerPropertyBrowsing)
  1284.         INIT_INTERFACE_PART(COleControl, PerPropertyBrowsing)
  1285.         STDMETHOD(GetDisplayString)(DISPID dispid, BSTR* lpbstr);
  1286.         STDMETHOD(MapPropertyToPage)(DISPID dispid, LPCLSID lpclsid);
  1287.         STDMETHOD(GetPredefinedStrings)(DISPID dispid,
  1288.             CALPOLESTR* lpcaStringsOut, CADWORD* lpcaCookiesOut);
  1289.         STDMETHOD(GetPredefinedValue)(DISPID dispid, DWORD dwCookie,
  1290.             VARIANT* lpvarOut);
  1291.     END_INTERFACE_PART_STATIC(PerPropertyBrowsing)
  1292.  
  1293.     // IPropertyNotifySink for font updates (not exposed via QueryInterface)
  1294.     BEGIN_INTERFACE_PART(FontNotification, IPropertyNotifySink)
  1295.         INIT_INTERFACE_PART(COleControl, FontNotification)
  1296.         STDMETHOD(OnChanged)(DISPID dispid);
  1297.         STDMETHOD(OnRequestEdit)(DISPID dispid);
  1298.     END_INTERFACE_PART_STATIC(FontNotification)
  1299.  
  1300.     // IQuickActivate
  1301.     BEGIN_INTERFACE_PART(QuickActivate, IQuickActivate)
  1302.         STDMETHOD(QuickActivate)(QACONTAINER *pQAContainer, QACONTROL *pqacontrol);
  1303.         STDMETHOD(SetContentExtent)(LPSIZEL lpsizel);
  1304.         STDMETHOD(GetContentExtent)(LPSIZEL lpsizel);
  1305.     END_INTERFACE_PART_STATIC(QuickActivate)
  1306.  
  1307.     // IPointerInactive
  1308.     BEGIN_INTERFACE_PART(PointerInactive, IPointerInactive)
  1309.         STDMETHOD(GetActivationPolicy)(DWORD* pdwPolicy);
  1310.         STDMETHOD(OnInactiveSetCursor)(LPCRECT lprcBounds, long x, long y,
  1311.             DWORD dwMouseMsg, BOOL bSetAlways);
  1312.         STDMETHOD(OnInactiveMouseMove)(LPCRECT lprcBounds, long x, long y,
  1313.             DWORD dwKeyState);
  1314.     END_INTERFACE_PART_STATIC(PointerInactive)
  1315.  
  1316.     DECLARE_INTERFACE_MAP()
  1317.  
  1318. // Connection maps
  1319. protected:
  1320.     // Connection point for events
  1321.     BEGIN_CONNECTION_PART(COleControl, EventConnPt)
  1322.         virtual void OnAdvise(BOOL bAdvise);
  1323.         virtual REFIID GetIID();
  1324.         virtual LPUNKNOWN QuerySinkInterface(LPUNKNOWN pUnkSink);
  1325.     END_CONNECTION_PART(EventConnPt)
  1326.  
  1327.     // Connection point for property notifications
  1328.     BEGIN_CONNECTION_PART(COleControl, PropConnPt)
  1329.         CONNECTION_IID(IID_IPropertyNotifySink)
  1330.     END_CONNECTION_PART(PropConnPt)
  1331.  
  1332.     DECLARE_CONNECTION_MAP()
  1333. };
  1334.  
  1335. /////////////////////////////////////////////////////////////////////////////
  1336. // Registry functions
  1337.  
  1338. enum AFX_REG_FLAGS
  1339. {
  1340.     afxRegDefault               = 0x0000,
  1341.     afxRegInsertable            = 0x0001,
  1342.     afxRegApartmentThreading    = 0x0002,
  1343. };
  1344.  
  1345. BOOL AFXAPI AfxOleRegisterTypeLib(HINSTANCE hInstance, REFGUID tlid,
  1346.     LPCTSTR pszFileName = NULL, LPCTSTR pszHelpDir = NULL);
  1347.  
  1348. BOOL AFXAPI AfxOleUnregisterTypeLib(REFGUID tlid, WORD wVerMajor = 0,
  1349.     WORD wVerMinor = 0, LCID lcid = 0);
  1350.  
  1351. BOOL AFXAPI AfxOleRegisterControlClass(HINSTANCE hInstance, REFCLSID clsid,
  1352.     LPCTSTR pszProgID, UINT idTypeName, UINT idBitmap, int nRegFlags,
  1353.     DWORD dwMiscStatus, REFGUID tlid, WORD wVerMajor, WORD wVerMinor);
  1354.  
  1355. BOOL AFXAPI AfxOleUnregisterClass(REFCLSID clsid, LPCTSTR pszProgID);
  1356.  
  1357. BOOL AFXAPI AfxOleRegisterPropertyPageClass(HINSTANCE hInstance,
  1358.     REFCLSID clsid, UINT idTypeName);
  1359.  
  1360. BOOL AFXAPI AfxOleRegisterPropertyPageClass(HINSTANCE hInstance,
  1361.     REFCLSID clsid, UINT idTypeName, int nRegFlags);
  1362.  
  1363. /////////////////////////////////////////////////////////////////////////////
  1364. // Licensing functions
  1365.  
  1366. WCE_DEL BOOL AFXAPI AfxVerifyLicFile(HINSTANCE hInstance, LPCTSTR pszLicFileName,
  1367. WCE_DEL     LPCOLESTR pszLicFileContents, UINT cch=-1);
  1368.  
  1369. /////////////////////////////////////////////////////////////////////////////
  1370. // CPropExchange - Abstract base class for property exchange
  1371.  
  1372. #ifdef _AFXDLL
  1373. class CPropExchange
  1374. #else
  1375. class AFX_NOVTABLE CPropExchange
  1376. #endif
  1377. {
  1378. // Operations
  1379. public:
  1380.     BOOL IsLoading();
  1381.     DWORD GetVersion();
  1382.  
  1383.     BOOL IsAsynchronous();
  1384.     // FALSE -> Do Sync stuff, and start async stuff if possible
  1385.     // TRUE -> Do not do Sync stuff.  Always start Async stuff
  1386.  
  1387.     virtual BOOL ExchangeVersion(DWORD& dwVersionLoaded, DWORD dwVersionDefault,
  1388.         BOOL bConvert);
  1389.  
  1390.     virtual BOOL ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
  1391.                 void* pvProp, const void* pvDefault = NULL) = 0;
  1392.     virtual BOOL ExchangeBlobProp(LPCTSTR pszPropName, HGLOBAL* phBlob,
  1393.                 HGLOBAL hBlobDefault = NULL) = 0;
  1394.     virtual BOOL ExchangeFontProp(LPCTSTR pszPropName, CFontHolder& font,
  1395.                 const FONTDESC* pFontDesc,
  1396.                 LPFONTDISP pFontDispAmbient) = 0;
  1397.     virtual BOOL ExchangePersistentProp(LPCTSTR pszPropName,
  1398.                 LPUNKNOWN* ppUnk, REFIID iid, LPUNKNOWN pUnkDefault) = 0;
  1399.  
  1400. // Implementation
  1401. protected:
  1402.     CPropExchange();
  1403.     BOOL m_bLoading;
  1404.     BOOL m_bAsync;
  1405.     DWORD m_dwVersion;
  1406. };
  1407.  
  1408. /////////////////////////////////////////////////////////////////////////////
  1409. // Property-exchange (PX_) helper functions
  1410.  
  1411. BOOL AFX_CDECL PX_Short(CPropExchange* pPX, LPCTSTR pszPropName, short& sValue);
  1412.  
  1413. BOOL AFX_CDECL PX_Short(CPropExchange* pPX, LPCTSTR pszPropName, short& sValue,
  1414.     short sDefault);
  1415.  
  1416. BOOL AFX_CDECL PX_UShort(CPropExchange* pPX, LPCTSTR pszPropName, USHORT& usValue);
  1417.  
  1418. BOOL AFX_CDECL PX_UShort(CPropExchange* pPX, LPCTSTR pszPropName, USHORT& usValue,
  1419.     USHORT usDefault);
  1420.  
  1421. BOOL AFX_CDECL PX_Long(CPropExchange* pPX, LPCTSTR pszPropName, long& lValue);
  1422.  
  1423. BOOL AFX_CDECL PX_Long(CPropExchange* pPX, LPCTSTR pszPropName, long& lValue,
  1424.     long lDefault);
  1425.  
  1426. BOOL AFX_CDECL PX_ULong(CPropExchange* pPX, LPCTSTR pszPropName, ULONG& ulValue);
  1427.  
  1428. BOOL AFX_CDECL PX_ULong(CPropExchange* pPX, LPCTSTR pszPropName, ULONG& ulValue,
  1429.     ULONG ulDefault);
  1430.  
  1431. BOOL AFX_CDECL PX_Color(CPropExchange* pPX, LPCTSTR pszPropName, OLE_COLOR& clrValue);
  1432.  
  1433. BOOL AFX_CDECL PX_Color(CPropExchange* pPX, LPCTSTR pszPropName, OLE_COLOR& clrValue,
  1434.     OLE_COLOR clrDefault);
  1435.  
  1436. BOOL AFX_CDECL PX_Bool(CPropExchange* pPX, LPCTSTR pszPropName, BOOL& bValue);
  1437.  
  1438. BOOL AFX_CDECL PX_Bool(CPropExchange* pPX, LPCTSTR pszPropName, BOOL& bValue,
  1439.     BOOL bDefault);
  1440.  
  1441. BOOL AFX_CDECL PX_String(CPropExchange* pPX, LPCTSTR pszPropName, CString& strValue);
  1442.  
  1443. BOOL AFX_CDECL PX_String(CPropExchange* pPX, LPCTSTR pszPropName, CString& strValue,
  1444.     const CString& strDefault);
  1445. BOOL AFX_CDECL PX_String(CPropExchange* pPX, LPCTSTR pszPropName, CString& strValue,
  1446.     LPCTSTR lpszDefault);
  1447.  
  1448. BOOL AFX_CDECL PX_Currency(CPropExchange* pPX, LPCTSTR pszPropName, CY& cyValue);
  1449.  
  1450. BOOL AFX_CDECL PX_Currency(CPropExchange* pPX, LPCTSTR pszPropName, CY& cyValue,
  1451.     CY cyDefault);
  1452.  
  1453. BOOL AFX_CDECL PX_Float(CPropExchange* pPX, LPCTSTR pszPropName, float& floatValue);
  1454.  
  1455. BOOL AFX_CDECL PX_Float(CPropExchange* pPX, LPCTSTR pszPropName, float& floatValue,
  1456.     float floatDefault);
  1457.  
  1458. BOOL AFX_CDECL PX_Double(CPropExchange* pPX, LPCTSTR pszPropName, double& doubleValue);
  1459.  
  1460. BOOL AFX_CDECL PX_Double(CPropExchange* pPX, LPCTSTR pszPropName, double& doubleValue,
  1461.     double doubleDefault);
  1462.  
  1463. BOOL AFX_CDECL PX_Blob(CPropExchange* pPX, LPCTSTR pszPropName, HGLOBAL& hBlob,
  1464.     HGLOBAL hBlobDefault = NULL);
  1465.  
  1466. BOOL AFX_CDECL PX_Font(CPropExchange* pPX, LPCTSTR pszPropName, CFontHolder& font,
  1467.     const FONTDESC* pFontDesc = NULL,
  1468.     LPFONTDISP pFontDispAmbient = NULL);
  1469.  
  1470. BOOL AFX_CDECL PX_Picture(CPropExchange* pPX, LPCTSTR pszPropName,
  1471.     CPictureHolder& pict);
  1472.  
  1473. BOOL AFX_CDECL PX_Picture(CPropExchange* pPX, LPCTSTR pszPropName,
  1474.     CPictureHolder& pict, CPictureHolder& pictDefault);
  1475.  
  1476. BOOL AFX_CDECL PX_IUnknown(CPropExchange* pPX, LPCTSTR pszPropName, LPUNKNOWN& pUnk,
  1477.     REFIID iid, LPUNKNOWN pUnkDefault = NULL);
  1478.  
  1479. BOOL AFX_CDECL PX_VBXFontConvert(CPropExchange* pPX, CFontHolder& font);
  1480.  
  1481. BOOL AFX_CDECL PX_DataPath(CPropExchange* pPX, LPCTSTR pszPropName,
  1482.     CDataPathProperty& dataPathProp, LPCTSTR pszDefault = NULL);
  1483.  
  1484. BOOL AFX_CDECL PX_DataPath(CPropExchange* pPX, LPCTSTR pszPropName,
  1485.     CDataPathProperty& dataPathProp, const CString& strDefault);
  1486.  
  1487. /////////////////////////////////////////////////////////////////////////////
  1488. // Structures used by COlePropertyPage
  1489.  
  1490. typedef struct tagAFX_PPFIELDSTATUS
  1491. {
  1492.     UINT    nID;
  1493.     BOOL    bDirty;
  1494.  
  1495. } AFX_PPFIELDSTATUS;
  1496.  
  1497. /////////////////////////////////////////////////////////////////////////////
  1498. // Property Page Dialog Class
  1499.  
  1500. #ifdef _AFXDLL
  1501. class COlePropertyPage : public CDialog
  1502. #else
  1503. class AFX_NOVTABLE COlePropertyPage : public CDialog
  1504. #endif
  1505. {
  1506.     DECLARE_DYNAMIC(COlePropertyPage)
  1507.  
  1508. // Constructors
  1509. public:
  1510.     COlePropertyPage(UINT idDlg, UINT idCaption);
  1511.  
  1512. // Operations
  1513.     LPDISPATCH* GetObjectArray(ULONG* pnObjects);
  1514.     void SetModifiedFlag(BOOL bModified = TRUE);
  1515.     BOOL IsModified();
  1516.     LPPROPERTYPAGESITE GetPageSite();
  1517.     void SetDialogResource(HGLOBAL hDialog);
  1518.     void SetPageName(LPCTSTR lpszPageName);
  1519.     void SetHelpInfo(LPCTSTR lpszDocString, LPCTSTR lpszHelpFile = NULL,
  1520.         DWORD dwHelpContext = 0);
  1521.  
  1522.     BOOL GetControlStatus(UINT nID);
  1523.     BOOL SetControlStatus(UINT nID, BOOL bDirty);
  1524.     void IgnoreApply(UINT nID);
  1525.  
  1526.     int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
  1527.             UINT nType = MB_OK);
  1528.     // note that this is a non-virtual override of CWnd::MessageBox()
  1529.  
  1530. // Overridables
  1531.     virtual void OnSetPageSite();
  1532.     virtual void OnObjectsChanged();
  1533.     virtual BOOL OnHelp(LPCTSTR lpszHelpDir);
  1534.     virtual BOOL OnInitDialog();
  1535.     virtual BOOL OnEditProperty(DISPID dispid);
  1536.  
  1537. // Implementation
  1538.  
  1539.     // DDP_ property get/set helper routines
  1540.     BOOL SetPropText(LPCTSTR pszPropName, BYTE &Value);
  1541.     BOOL GetPropText(LPCTSTR pszPropName, BYTE* pValue);
  1542.     BOOL SetPropText(LPCTSTR pszPropName, short &Value);
  1543.     BOOL GetPropText(LPCTSTR pszPropName, short* pValue);
  1544.     BOOL SetPropText(LPCTSTR pszPropName, int &Value);
  1545.     BOOL GetPropText(LPCTSTR pszPropName, int* pValue);
  1546.     BOOL SetPropText(LPCTSTR pszPropName, UINT &Value);
  1547.     BOOL GetPropText(LPCTSTR pszPropName, UINT* pValue);
  1548.     BOOL SetPropText(LPCTSTR pszPropName, long &Value);
  1549.     BOOL GetPropText(LPCTSTR pszPropName, long* pValue);
  1550.     BOOL SetPropText(LPCTSTR pszPropName, DWORD &Value);
  1551.     BOOL GetPropText(LPCTSTR pszPropName, DWORD* pValue);
  1552.     BOOL SetPropText(LPCTSTR pszPropName, CString &Value);
  1553.     BOOL GetPropText(LPCTSTR pszPropName, CString* pValue);
  1554.     BOOL SetPropText(LPCTSTR pszPropName, float &Value);
  1555.     BOOL GetPropText(LPCTSTR pszPropName, float* pValue);
  1556.     BOOL SetPropText(LPCTSTR pszPropName, double &Value);
  1557.     BOOL GetPropText(LPCTSTR pszPropName, double* pValue);
  1558.     BOOL SetPropCheck(LPCTSTR pszPropName, int Value);
  1559.     BOOL GetPropCheck(LPCTSTR pszPropName, int* pValue);
  1560.     BOOL SetPropRadio(LPCTSTR pszPropName, int Value);
  1561.     BOOL GetPropRadio(LPCTSTR pszPropName, int* pValue);
  1562.     BOOL SetPropIndex(LPCTSTR pszPropName, int Value);
  1563.     BOOL GetPropIndex(LPCTSTR pszPropName, int* pValue);
  1564.     CPtrArray m_arrayDDP;      // pending DDP data
  1565.  
  1566.     // Destructors
  1567.     ~COlePropertyPage();
  1568.  
  1569. protected:
  1570.     LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
  1571.     BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  1572.     BOOL PreTranslateMessage(LPMSG lpMsg);
  1573.     virtual void OnFinalRelease();
  1574.     void CleanupObjectArray();
  1575.     static BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
  1576.     static BOOL CALLBACK EnumControls(HWND hWnd, LPARAM lParam);
  1577.  
  1578. private:
  1579.     BOOL m_bDirty;
  1580.     UINT m_idDlg;
  1581.     UINT m_idCaption;
  1582.     CString m_strPageName;
  1583.     SIZE m_sizePage;
  1584.     CString m_strDocString;
  1585.     CString m_strHelpFile;
  1586.     DWORD m_dwHelpContext;
  1587.     LPPROPERTYPAGESITE m_pPageSite;
  1588.  
  1589.     LPDISPATCH* m_ppDisp;   // Array of IDispatch pointers, used to
  1590.                                 // access the properties of each control
  1591.  
  1592.     LPDWORD m_pAdvisors;        // Array of connection tokens used by
  1593.                                 // IConnecitonPoint::Advise/UnAdvise.
  1594.  
  1595.     BOOL m_bPropsChanged;       // IPropertyNotifySink::OnChanged has been
  1596.                                 // called, but not acted upon yet.
  1597.  
  1598.     ULONG m_nObjects;           // Objects in m_ppDisp, m_ppDataObj, m_pAdvisors
  1599.  
  1600.     BOOL m_bInitializing;       // TRUE if the contents of the fields of
  1601.                                 // the dialog box are being initialized
  1602.  
  1603.     int m_nControls;            // Number of fields on this property page
  1604.  
  1605.     AFX_PPFIELDSTATUS* m_pStatus;   // Array containing information on
  1606.                                     // which fields are dirty
  1607.  
  1608.     CDWordArray m_IDArray;      // Array containing information on which
  1609.                                 // controls to ignore when deciding if
  1610.                                 // the apply button is to be enabled
  1611.  
  1612.     HGLOBAL m_hDialog;          // Handle of the dialog resource
  1613.  
  1614. #ifdef _DEBUG
  1615. protected:
  1616.     BOOL m_bNonStandardSize;
  1617. #endif
  1618.  
  1619. protected:
  1620.     // Generated message map functions
  1621.     //{{AFX_MSG(COlePropertyPage)
  1622.     afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  1623.     //}}AFX_MSG
  1624.     DECLARE_MESSAGE_MAP()
  1625.  
  1626. // Interface Maps
  1627. public:
  1628.     BEGIN_INTERFACE_PART(PropertyPage, IPropertyPage2)
  1629.         INIT_INTERFACE_PART(COlePropertyPage, PropertyPage)
  1630.         STDMETHOD(SetPageSite)(LPPROPERTYPAGESITE);
  1631.         STDMETHOD(Activate)(HWND, LPCRECT, BOOL);
  1632.         STDMETHOD(Deactivate)();
  1633.         STDMETHOD(GetPageInfo)(LPPROPPAGEINFO);
  1634.         STDMETHOD(SetObjects)(ULONG, LPUNKNOWN*);
  1635.         STDMETHOD(Show)(UINT);
  1636.         STDMETHOD(Move)(LPCRECT);
  1637.         STDMETHOD(IsPageDirty)();
  1638.         STDMETHOD(Apply)();
  1639.         STDMETHOD(Help)(LPCOLESTR);
  1640.         STDMETHOD(TranslateAccelerator)(LPMSG);
  1641.         STDMETHOD(EditProperty)(DISPID);
  1642.     END_INTERFACE_PART(PropertyPage)
  1643.  
  1644.     BEGIN_INTERFACE_PART(PropNotifySink, IPropertyNotifySink)
  1645.         INIT_INTERFACE_PART(COlePropertyPage, PropNotifySink)
  1646.         STDMETHOD(OnRequestEdit)(DISPID);
  1647.         STDMETHOD(OnChanged)(DISPID);
  1648.     END_INTERFACE_PART(PropNotifySink)
  1649.  
  1650.     DECLARE_INTERFACE_MAP()
  1651. };
  1652.  
  1653. /////////////////////////////////////////////////////////////////////////////
  1654. //  CStockPropPage
  1655.  
  1656. #ifdef _AFXDLL
  1657. class CStockPropPage : public COlePropertyPage
  1658. #else
  1659. class AFX_NOVTABLE CStockPropPage : public COlePropertyPage
  1660. #endif
  1661. {
  1662.     DECLARE_DYNAMIC(CStockPropPage)
  1663.  
  1664. // Constructor
  1665. public:
  1666.     CStockPropPage(UINT idDlg, UINT idCaption);
  1667.  
  1668. // Implementation
  1669. protected:
  1670.     void FillPropnameList(REFGUID guid, int nIndirect, CComboBox& combo);
  1671.     void OnSelchangePropname(CComboBox& combo);
  1672.     BOOL OnEditProperty(DISPID dispid, CComboBox& combo);
  1673.  
  1674.     LCID m_lcid;
  1675.     CString m_strPropName;
  1676.     int m_iPropName;
  1677.  
  1678.     DECLARE_MESSAGE_MAP()
  1679. };
  1680.  
  1681. ///////////////////////////////////////////////////////////////////////////////
  1682. // CColorButton: used by CColorPropPage
  1683.  
  1684. class CColorButton : public CButton
  1685. {
  1686. public:
  1687.     CColorButton(void);
  1688.     void SetFaceColor(COLORREF colFace);
  1689.     COLORREF colGetFaceColor(void);
  1690.     void SetState(BOOL fSelected);
  1691.     static UINT idClicked;
  1692. protected:
  1693.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  1694. private:
  1695.     BOOL m_fSelected;
  1696.     COLORREF m_colFace;
  1697. };
  1698.  
  1699. /////////////////////////////////////////////////////////////////////////////
  1700. // CColorPropPage
  1701.  
  1702. class CColorPropPage : public CStockPropPage
  1703. {
  1704.     DECLARE_DYNCREATE(CColorPropPage)
  1705. #ifdef _AFXDLL
  1706.     DECLARE_OLECREATE_EX(CColorPropPage)
  1707. #endif
  1708.  
  1709. // Construction
  1710. public:
  1711.     CColorPropPage();   // Constructor
  1712.  
  1713. // Dialog Data
  1714.     //{{AFX_DATA(CColorPropPage)
  1715.     enum { IDD = AFX_IDD_PROPPAGE_COLOR };
  1716.     CComboBox   m_SysColors;
  1717.     CComboBox   m_ColorProp;
  1718.     //}}AFX_DATA
  1719.  
  1720. // Implementation
  1721. public:
  1722.     enum { NBUTTONS = 16 };
  1723.  
  1724. protected:
  1725.     virtual void DoDataExchange(CDataExchange* pDX);        // DDX/DDV support
  1726.     virtual BOOL OnInitDialog(void);
  1727.     virtual BOOL OnEditProperty(DISPID dispid);
  1728.     virtual void OnObjectsChanged();
  1729.     void FillSysColors();
  1730.     BOOL SetColorProp(CDataExchange* pDX, COLORREF color, LPCTSTR pszPropName);
  1731.     BOOL GetColorProp(CDataExchange* pDX, COLORREF* pcolor, LPCTSTR pszPropName);
  1732.  
  1733. private:
  1734.     CColorButton m_Buttons[NBUTTONS];
  1735.     CColorButton *m_pSelectedButton;
  1736.  
  1737.     void SetButton(CColorButton *Button);
  1738.  
  1739.     // Generated message map functions
  1740.     //{{AFX_MSG(CColorPropPage)
  1741.     afx_msg void OnSelchangeColorprop();
  1742.     afx_msg void OnSelect(void);
  1743.     afx_msg void OnSelchangeSystemcolors();
  1744.     //}}AFX_MSG
  1745.  
  1746.     DECLARE_MESSAGE_MAP()
  1747. };
  1748.  
  1749. // Stores all the information about a font
  1750. typedef struct tagFONTOBJECT
  1751. {
  1752.     CString strName;
  1753.     CY  cySize;
  1754.     BOOL bBold;
  1755.     BOOL bItalic;
  1756.     BOOL bUnderline;
  1757.     BOOL bStrikethrough;
  1758.     short sWeight;
  1759. } FONTOBJECT;
  1760.  
  1761. // Merge objects are used when trying to consolidate multiple font properties.
  1762. // If the characteristics of these multiple properties differ then this is
  1763. // represented in the merge object.
  1764. typedef struct tagMERGEOBJECT
  1765. {
  1766.     BOOL bNameOK;
  1767.     BOOL bSizeOK;
  1768.     BOOL bStyleOK;
  1769.     BOOL bUnderlineOK;
  1770.     BOOL bStrikethroughOK;
  1771. } MERGEOBJECT;
  1772.  
  1773. /////////////////////////////////////////////////////////////////////////////
  1774. // CSizeComboBox window
  1775.  
  1776. class CSizeComboBox : public CComboBox
  1777. {
  1778. // Operations
  1779. public:
  1780.     int AddSize(int PointSize, LONG lfHeight);
  1781.  
  1782.     void            GetPointSize(CY& cy);
  1783.     LONG            GetHeight(int sel=-1);
  1784.     void            UpdateLogFont( LPLOGFONT lpLF, int sel=-1 );
  1785. };
  1786.  
  1787. /////////////////////////////////////////////////////////////////////////////
  1788. // CFontComboBox window
  1789.  
  1790. struct FONTITEM_PPG
  1791. {
  1792.     DWORD dwFontType;
  1793.     LOGFONT lf;
  1794. };
  1795.  
  1796. class CFontComboBox : public CComboBox
  1797. {
  1798. // Construction
  1799. public:
  1800.     CFontComboBox();
  1801.     virtual ~CFontComboBox();
  1802.  
  1803. // Operations
  1804. public:
  1805.     int AddFont(LOGFONT *, DWORD);
  1806.     CString GetCurrentName();
  1807.  
  1808.     FONTITEM_PPG* GetFontItem(int sel=-1);
  1809.     LPLOGFONT GetLogFont(int sel=-1);
  1810.     DWORD GetFontType(int sel=-1);
  1811.  
  1812. // Implementation
  1813. public:
  1814.     virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
  1815.     virtual void DeleteItem(LPDELETEITEMSTRUCT lpDIS);
  1816.  
  1817. protected:
  1818.     CBitmap m_bmpTrueType;
  1819.     CBitmap m_bmpMask;
  1820. };
  1821.  
  1822. ///////////////////////////////////////////////////////////////////////////
  1823. // CFontPropPage class
  1824.  
  1825. class CFontPropPage : public CStockPropPage
  1826. {
  1827.     DECLARE_DYNCREATE(CFontPropPage)
  1828. #ifdef _AFXDLL
  1829.     DECLARE_OLECREATE_EX(CFontPropPage)
  1830. #endif
  1831.  
  1832. public:
  1833.     CFontPropPage();
  1834.  
  1835.     // Dialog Data
  1836.     //{{AFX_DATA(CFontPropPage)
  1837.     enum { IDD = AFX_IDD_PROPPAGE_FONT };
  1838.     CComboBox   m_FontProp;
  1839.     CStatic m_SampleBox;
  1840.     CComboBox   m_FontStyles;
  1841.     CSizeComboBox   m_FontSizes;
  1842.     CFontComboBox   m_FontNames;
  1843.     //}}AFX_DATA
  1844.  
  1845. // Attributes
  1846. protected:
  1847.     int nPixelsY;
  1848.     CFont SampleFont;
  1849.     DWORD m_nCurrentStyle;
  1850.     DWORD m_nActualStyle;
  1851.     DWORD m_nStyles;
  1852.     BOOL m_bStrikeOut;
  1853.     BOOL m_bUnderline;
  1854.     CString m_strFontSize;
  1855.  
  1856. // Implementation
  1857. protected:
  1858.  
  1859.     void FillFacenameList();
  1860.     void FillSizeList();
  1861.     virtual void DoDataExchange(CDataExchange* pDX);
  1862.     virtual void OnPaint();
  1863.     virtual BOOL OnEditProperty(DISPID dispid);
  1864.     virtual void OnObjectsChanged();
  1865.     void UpdateSampleFont();
  1866.     void SelectFontFromList(CString strFaceName, MERGEOBJECT* pmobj);
  1867.  
  1868.     //{{AFX_MSG(CFontPropPage)
  1869.     virtual BOOL OnInitDialog();
  1870.     afx_msg void OnEditupdateFontnames();
  1871.     afx_msg void OnEditupdateFontsizes();
  1872.     afx_msg void OnSelchangeFontnames();
  1873.     afx_msg void OnSelchangeFontsizes();
  1874.     afx_msg void OnSelchangeFontstyles();
  1875.     afx_msg void OnEditchangeFontstyles();
  1876.     afx_msg void OnStrikeout();
  1877.     afx_msg void OnUnderline();
  1878.     afx_msg void OnSelchangeFontprop();
  1879.     //}}AFX_MSG
  1880.     DECLARE_MESSAGE_MAP()
  1881.  
  1882.     static int CALLBACK EnumFontFamiliesCallBack(ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm, int FontType, LPARAM lParam);
  1883.     static int CALLBACK EnumFontFamiliesCallBack2(ENUMLOGFONT* lpelf, NEWTEXTMETRIC* lpntm, int FontType, LPARAM lParam);
  1884.  
  1885.     BOOL SetFontProps(CDataExchange* pDX, FONTOBJECT fobj, LPCTSTR pszPropName);
  1886.     BOOL GetFontProps(CDataExchange* pDX, FONTOBJECT*  pfobj, LPCTSTR pszPropName, MERGEOBJECT* pmobj);
  1887. };
  1888.  
  1889. ////////////////////////////////////////////////////////////////////////////
  1890. //  CPicturePropPage
  1891.  
  1892. class CPicturePropPage : public CStockPropPage
  1893. {
  1894.     DECLARE_DYNCREATE(CPicturePropPage)
  1895. #ifdef _AFXDLL
  1896.     DECLARE_OLECREATE_EX(CPicturePropPage)
  1897. #endif
  1898.  
  1899. // Construction
  1900. public:
  1901.     CPicturePropPage(); // standard constructor
  1902.     ~CPicturePropPage();
  1903.  
  1904. // Dialog Data
  1905.     //{{AFX_DATA(CPicturePropPage)
  1906.     enum { IDD = AFX_IDD_PROPPAGE_PICTURE };
  1907.     CComboBox   m_PropName;
  1908.     CStatic m_Static;
  1909.     //}}AFX_DATA
  1910.  
  1911. // Implementation
  1912. protected:
  1913.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  1914.     virtual BOOL OnInitDialog(void);
  1915.     virtual BOOL OnEditProperty(DISPID dispid);
  1916.     virtual void OnObjectsChanged();
  1917.  
  1918.     BOOL SetPictureProp(CDataExchange* pDX, LPPICTUREDISP pPictDisp, LPCTSTR pszPropName);
  1919.     BOOL GetPictureProp(CDataExchange* pDX, LPPICTUREDISP* ppPictDisp, LPCTSTR pszPropName);
  1920.     void ChangePicture(LPPICTURE pPict);
  1921.  
  1922.     LPPICTUREDISP m_pPictDisp;
  1923.  
  1924. // Generated message map functions
  1925. protected:
  1926.     //{{AFX_MSG(CPicturePropPage)
  1927.     afx_msg void OnPaint();
  1928.     afx_msg void OnBrowse();
  1929.     afx_msg void OnClear();
  1930.     afx_msg void OnSelchangePictProp();
  1931.     //}}AFX_MSG
  1932.     DECLARE_MESSAGE_MAP()
  1933. };
  1934.  
  1935. /////////////////////////////////////////////////////////////////////////////
  1936. // Property Page Dialog Data Exchange routines
  1937.  
  1938. // simple text operations
  1939. void AFXAPI DDP_Text(CDataExchange*pDX, int id, BYTE& member, LPCTSTR pszPropName);
  1940. void AFXAPI DDP_Text(CDataExchange*pDX, int id, short& member, LPCTSTR pszPropName);
  1941. void AFXAPI DDP_Text(CDataExchange*pDX, int id, int& member, LPCTSTR pszPropName);
  1942. void AFXAPI DDP_Text(CDataExchange*pDX, int id, UINT& member, LPCTSTR pszPropName);
  1943. void AFXAPI DDP_Text(CDataExchange*pDX, int id, long& member, LPCTSTR pszPropName);
  1944. void AFXAPI DDP_Text(CDataExchange*pDX, int id, DWORD& member, LPCTSTR pszPropName);
  1945. void AFXAPI DDP_Text(CDataExchange*pDX, int id, float& member, LPCTSTR pszPropName);
  1946. void AFXAPI DDP_Text(CDataExchange*pDX, int id, double& member, LPCTSTR pszPropName);
  1947. void AFXAPI DDP_Text(CDataExchange*pDX, int id, CString& member, LPCTSTR pszPropName);
  1948. void AFXAPI DDP_Check(CDataExchange*pDX, int id, int& member, LPCTSTR pszPropName);
  1949. void AFXAPI DDP_Radio(CDataExchange*pDX, int id, int& member, LPCTSTR pszPropName);
  1950. void AFXAPI DDP_LBString(CDataExchange* pDX, int id, CString& member, LPCTSTR pszPropName);
  1951. void AFXAPI DDP_LBStringExact(CDataExchange* pDX, int id, CString& member, LPCTSTR pszPropName);
  1952. void AFXAPI DDP_LBIndex(CDataExchange* pDX, int id, int& member, LPCTSTR pszPropName);
  1953. void AFXAPI DDP_CBString(CDataExchange* pDX, int id, CString& member, LPCTSTR pszPropName);
  1954. void AFXAPI DDP_CBStringExact(CDataExchange* pDX, int id, CString& member, LPCTSTR pszPropName);
  1955. void AFXAPI DDP_CBIndex(CDataExchange* pDX, int id, int& member, LPCTSTR pszPropName);
  1956. void AFXAPI DDP_PostProcessing(CDataExchange *pDX);
  1957.  
  1958. ////////////////////////////////////////////////////////////////////////////
  1959. // AfxOleTypeMatchGuid - Tests whether a given TYPEDESC matches a type with a
  1960. // given GUID, when all aliases have been expanded.
  1961.  
  1962. BOOL AFXAPI AfxOleTypeMatchGuid(LPTYPEINFO pTypeInfo,
  1963.     TYPEDESC* pTypeDesc, REFGUID guidType, ULONG cIndirectionLevels);
  1964.  
  1965. /////////////////////////////////////////////////////////////////////////////
  1966. // Inline function declarations
  1967.  
  1968. #ifdef _AFX_PACKING
  1969. #pragma pack(pop)
  1970. #endif
  1971.  
  1972. #ifdef _AFX_ENABLE_INLINES
  1973. #define _AFXCTL_INLINE AFX_INLINE
  1974. #include <afxctl.inl>
  1975. #endif
  1976.  
  1977. #undef AFX_DATA
  1978. #define AFX_DATA
  1979.  
  1980. #ifdef _AFX_MINREBUILD
  1981. #pragma component(minrebuild, on)
  1982. #endif
  1983. #ifndef _AFX_FULLTYPEINFO
  1984. #pragma component(mintypeinfo, off)
  1985. #endif
  1986.  
  1987. #endif // __AFXCTL_H__
  1988.  
  1989. /////////////////////////////////////////////////////////////////////////////
  1990.